if CLIENT then
	include("shared.lua")
	
	SWEP.IconFont = "CSSelectIcons"
	
	SWEP.DrawAmmo			= false
	SWEP.DrawCrosshair		= false
	SWEP.ViewModelFOV		= 75
	SWEP.ViewModelFlip		= false
	SWEP.CSMuzzleFlashes	= false
	
	function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
		draw.SimpleText( "C", self.IconFont, x + wide/2, y + tall*0.2, Color( 200, 20, 15, 255 ), TEXT_ALIGN_CENTER )
	end
end

SWEP.Author = "Rambo_6"
SWEP.HoldType = "slam"

SWEP.ViewModel = "models/Zed/weapons/v_banshee.mdl"
SWEP.WorldModel = ""

SWEP.Primary.Damage = 20
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo	= "none"

function SWEP:GetPrintName()
	return "Zombie"
end

function SWEP:Initialize()
	if SERVER then
		self:SetWeaponHoldType(self.HoldType)
	end
end

function SWEP:Reload()
	return false
end

function SWEP:Deploy()
	if CLIENT then return end
	self.Owner:DrawWorldModel(false)
	self.Owner:CrosshairDisable()
end

SWEP.NextTalk = 0
function SWEP:SecondaryAttack()
	if self.NextTalk < CurTime() then
		self.NextTalk = CurTime() + 2
		self.Owner:VoiceSound(ChooseRandom(self.Owner.Taunt),100,.1)
		for k,v in pairs(team.GetPlayers(TEAM_HUMANS)) do
			if v:GetPos():Distance(self.Owner:GetPos()) < 300 then
				v:VoiceSound(ChooseRandom(v.Alert),100,math.Rand(0,3))
			end
		end
	end
end

SWEP.NextSwing = 0
function SWEP:PrimaryAttack()
	if CurTime() < self.NextSwing then return end
	self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
	self.Owner:SetAnimation(PLAYER_ATTACK1)
	self.Owner:EmitSound("npc/fast_zombie/idle1.wav",100,math.random(90,105))
	self.NextSwing = CurTime() + .9
	self.NextHit = CurTime() + 0.4
	local trace = util.GetPlayerTrace(self.Owner)
	local tr = util.TraceLine(trace)
	if tr.HitPos:Distance(self.Owner:GetShootPos()) < 75 then
		if tr.HitNonWorld then
			self.HitEnt = tr.Entity
		end
	end
end

function SWEP:Think()
	if not self.NextHit then return end
	if CurTime() < self.NextHit then return end
	self.NextHit = nil
	
	self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)

	if not self.HitEnt then
		local trace = util.GetPlayerTrace(self.Owner)
		local tr = util.TraceLine(trace)
		if tr.HitPos:Distance(self.Owner:GetShootPos()) < 75 then
			if tr.HitNonWorld then
				self.HitEnt = tr.Entity
			else
				self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
				util.Decal("Blood", tr.HitPos + tr.HitNormal, tr.HitPos - tr.HitNormal)
				return
			end
		end
	end
	if self.HitEnt then
		if self.HitEnt:IsValid() then
			self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
			local phys = self.HitEnt:GetPhysicsObject()
			
			if self.HitEnt:GetModel() == "models/props_debris/wood_chunk03a.mdl" or self.HitEnt:GetModel() == "models/props_debris/wood_chunk03b.mdl" then
				local hit = ChooseRandom(GameSounds.WoodHit)
				self.Owner:EmitSound(hit,100,math.random(90,110))
				self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
				self.HitEnt = nil
				return
			end
			
			if string.find(self.HitEnt:GetClass(),"npc") then
				local vel = self.Owner:EyeAngles():Forward() * 400
				vel.z = 200
				self.HitEnt:SetVelocity(vel)
			end
			
			if self.HitEnt:IsPlayer() then
				if self.HitEnt:Team() == TEAM_UNDEAD then
					local vel = self.Owner:EyeAngles():Forward() * 400
					vel.z = 200
					ent:SetVelocity(vel)
				else
					self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
					self.HitEnt:DoBlind()
					local effectdata = EffectData()
					effectdata:SetOrigin(self.HitEnt:GetPos() + Vector(0,0,55))
					effectdata:SetNormal(self.Owner:GetAimVector())
					util.Effect("zombie_hit", effectdata, true, true)
				end
			elseif string.find(self.HitEnt:GetClass(),"func_breakable") then
				self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
				self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
			elseif string.find(self.HitEnt:GetClass(),"prop_door") then
				local hit = ChooseRandom(GameSounds.WoodHit)
				if self.HitEnt.HitHealth then
					self.HitEnt.HitHealth = self.HitEnt.HitHealth - 10
					self.Owner:EmitSound(hit,100,math.random(90,110))
					if self.HitEnt.HitHealth <= 0 then
						self.Owner:EmitSound(ChooseRandom(GameSounds.WoodBreak),100,math.random(90,110))
						self.HitEnt:Fire("unlock",1,.1)
						self.HitEnt:Fire("open",1,.1)
						Inventory.RemoveDoor(self.HitEnt)
					end
				else
					self.HitEnt.HitHealth = 20
					self.Owner:EmitSound(hit,100,math.random(90,110))
				end
			elseif phys:IsValid() and string.find(self.HitEnt:GetClass(),"prop_physic") and phys:IsMoveable() then
				local vel = self.Owner:EyeAngles():Forward() * self.Primary.Damage * 800
				if vel.z < 1000 then
					vel.z = 1000 
				end
				phys:ApplyForceCenter(vel)
				self.HitEnt:SetPhysicsAttacker(self.Owner)
				self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
				self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
			end
		end
 	else
		self.Owner:EmitSound("npc/zombie/claw_miss"..math.random(1, 2)..".wav")
	end
	self.HitEnt = nil
end
